package com.bbex.service.impl;

import com.bbex.mapper.DictDetailDao;
import com.bbex.service.DictService;
import com.bbex.vo.DictDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class DictServiceImpl implements DictService {

    @Autowired
    private DictDetailDao dictDetailMapper;
    @Override
    public List<Map> getDictDetailByItemCode(String itemCode) {
        List<Map> dictDetailList =new ArrayList<>();
            Map param = new HashMap();
            param.put("itemCode",itemCode);
            List<DictDetail>dictDetails = dictDetailMapper.dictDetails(param);
            for (DictDetail detail:dictDetails) {
                Map dMap = new HashMap();
                dMap.put("dictName",detail.getDetailName());
                dictDetailList.add(dMap);
            }
        return dictDetailList;
    }

    @Override
    public Map getDictListByItemCode(String itemCode,String detail_code) {
        List<Map> dictDetailList=new ArrayList<>();
            Map param = new HashMap();
            param.put("itemCode",itemCode);
            param.put("detail_code",detail_code);
        List<DictDetail> list = dictDetailMapper.findList(param);
        Map dMap = new HashMap();
        dMap.put("dictName",list.get(0).getDetailName());
        dictDetailList.add(dMap);
        return dMap;
    }

}